<script>
$(document).ready(function() {
//// Start Contact Form ////
	$('#ajaxcontactform').submit(function(){$('input[type=submit]', this).attr('disabled', 'disabled');});
	
	
	$('#ajaxcontactform').submit(
	
		function parseResponse() {
	
		var usersname = $("#name");
		var usersemail = $("#email");
		var usersphonenumber = $("#phone");
		var usersmessage = $("#comment");
		var contactformid = $("#contactformid");
		var url = "modules/mod_contact/contact.php";
		
		var emailReg = new RegExp(/^(("[\w-\s]+")|([\w-]+(?:\.[\w-]+)*)|("[\w-\s]+")([\w-]+(?:\.[\w-]+)*))(@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$)|(@\[?((25[0-5]\.|2[0-4][0-9]\.|1[0-9]{2}\.|[0-9]{1,2}\.))((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\.){2}(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\]?$)/i);
		var valid = emailReg.test(usersemail.val());
		
		if(!valid) {
			$("#contactwarning").html('<p class="rejectionalert"><span>Your email is not valid!</span></p>').slideDown().delay(2000).slideUp();
			$('input[type=submit]', $("#ajaxcontactform")).removeAttr('disabled');
			return false;
		}
		
		if (usersname.val() == "" || usersname.val() == "Please Insert Your Name") {				  
		   $("#contactwarning").html('<p class="rejectionalert"><span>Please Insert Your Name!</span></p>').slideDown().delay(2000).slideUp();
		   $('input[type=submit]', $("#ajaxcontactform")).removeAttr('disabled');
		   return false;			   
		}
		if (usersemail.val() == "" || usersemail.val() == "Please Insert Your Email") {
		   $("#contactwarning").html('<p class="rejectionalert"><span>Please Insert Your Email!</span></p>').slideDown().delay(2000).slideUp();
		   $('input[type=submit]', $("#ajaxcontactform")).removeAttr('disabled');
		   return false;
		}
		if (usersphonenumber.val() == "" || usersphonenumber.val() == "Please Insert Your Phone Number") {
		   $("#contactwarning").html('<p class="rejectionalert"><span>Please Insert Your Phone Number!</span></p>').slideDown().delay(2000).slideUp();
		   $('input[type=submit]', $("#ajaxcontactform")).removeAttr('disabled');
		   return false;
		}
		if (usersmessage.val() == "" || usersmessage.val() == "Please Leave A Message") {
		   $("#contactwarning").html('<p class="rejectionalert"><span>You forgot to leave a message!</span></p>').slideDown().delay(2000).slideUp();
		   $('input[type=submit]', $("#ajaxcontactform")).removeAttr('disabled');
		   return false;
		}
		
		$.post(url,{ usersname: usersname.val(), usersemail: usersemail.val(), usersphonenumber: usersphonenumber.val(), usersmessage: usersmessage.val(), contactformid: contactformid.val() } , function(data) {
			$('#contactajax').html(data);
			$('#contactajax').slideDown().delay(3000).slideUp();
			$("#name").val('Please Insert Your Name');
			$("#email").val('Please Insert Your Email');
			$("#phone").val('Please Insert Your Phone Number');
			$("#comment").val('Please Leave A Message');
			$('input[type=submit]', $("#ajaxcontactform")).removeAttr('disabled');
		});
			  
		}
	  
	  );
//// End Contact Form ////

 });
 
 //window.onload = initialize;

 
</script> 

    <!-- Start H1 Title -->
    <div class="titlesnormal">
    
    	<h1>contact me</h1>
        
        <span></span>
    
    </div>
    <!-- End H1 Title -->
    <!-- Start Main Body Wrap -->
    <div id="main-wrap">
        
        <!-- Start Left Section -->
        <div class="leftsection">

            <!-- Start Google Maps -->
        	<div class="blogwrapstart">
            
            	<div style="height:175px; width:612px; margin:7px;">
       	      		<img src="images/contact/contact.png" width="612" height="175" /></div>
                <span class="box-arrow"></span>
            
            </div>
            <!-- End Google Maps -->
        
        </div>
        <!-- End Left Section -->
        
        <!-- Start Right Section -->
        <div class="rightsection">
            
        	<!-- Start Blog Widget -->
            <div class="blogwidgetstart">
            	<!-- Start Categories Widget -->
            	<div class="widgettitle"><h4>Contact Details</h4></div>
                
                <div class="widgetbody" style="padding-top:5px;">                
                    <div class="" style="padding-left:15px;">                    
                        <p class="emailicon"> inancm.dev@gmail.com</p>
                        <p class="phoneicon"> +6684 176 9534</p>
                        <p class="homeicon"> Wing 41 10/513 Moo 3<br />Suthep Muang,<br />Chiang Mai 50200,<br />THAILAND</p>    
                    </div>             
                </div>
              <!-- End Categories Widget -->
              <span class="box-arrow"></span>
            
            </div>
            <!-- End Blog Widget -->
        
        </div>
        <!-- End Right Section -->
        
        <!-- Start Full Width -->
        <div class="boxes-full">
        
            <div class="contacttitle">
            
                <h2>Contact Responsive</h2>
            
            </div>
        
        	<div class="boxes-padding fullpadding">
            
            <div id="contactwarning"></div>
            <div id="contactajax"></div>
            
            <form action="javascript:parseResponse();" method="post" name="ajaxcontactform" id="ajaxcontactform">
            
            	<div class="contacttextarea">
                	<input name="contactformid" id="contactformid" type="hidden" value="1" />
                
                	<fieldset>
                    	<textarea name="comment" id="comment" cols="5" rows="5" class="contacttextarea"onfocus="if (this.value == 'Please Leave A Message') {this.value = '';}">Please Leave A Message</textarea>
                    </fieldset>
                
                </div>
                
                <div class="contacttextboxes">
                
                	<fieldset>
                    	<input id="name" name="name" type="text" class="contacttextform" onfocus="if (this.value == 'Please Insert Your Name') {this.value = '';}" value="Please Insert Your Name">
                    </fieldset>
                    
                	<fieldset>
                    	<input id="phone" name="phone" type="text" class="contacttextform" onfocus="if (this.value == 'Please Insert Your Phone Number') {this.value = '';}" value="Please Insert Your Phone Number">
                    </fieldset>
                    
                	<fieldset>
                    	<input id="email" name="email" type="text" class="contacttextform" onfocus="if (this.value == 'Please Insert Your Email') {this.value = '';}" value="Please Insert Your Email">
                    </fieldset>
                    
                	<fieldset>
                    	<input name="send" type="submit" class="contactformbutton" value="Send">
                    </fieldset>
                
                </div>
                
            </form>
            
            </div>
            
            <span class="box-arrow"></span>
            
        </div>
        <!-- End Full Width -->
        
    </div>
    <!-- End Main Body Wrap -->

